﻿using System;
using System.Collections.Generic;
using Missbot.Service;
using MongoDB.Bson.Serialization.Attributes;

namespace Missbot.AIModule.Gaming.DriftBottle
{
    public class DriftBottleRecord : DbBaseEntity
    {
        public string FromGroupID { get; set; }

        public string FromUserID { get; init; }

        public string ReceivedGroupID { get; set; }

        public string ReceivedUserID { get; set; }

        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime SendTime { get; set; }

        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime? ReceivedTime { get; set; }

        public string Content { get; init; }

        public string SignName { get; set; } = "陌生人";
    }

    public static class DriftBottleRecordDA
    {
        public static List<DriftBottleRecord> GetOthers(string userID)
        {
            return MongoService<DriftBottleRecord>.Get(r => r.FromUserID != userID && r.ReceivedUserID == null);
        }

        public static void Update(this DriftBottleRecord entity)
        {
            MongoService<DriftBottleRecord>.Update(entity);
        }

        public static void Insert(this DriftBottleRecord entity)
        {
            MongoService<DriftBottleRecord>.Insert(entity);
        }
    }
}